// 暴露自定义插件对象
import SvgIcon from "./SvgIcon/index.vue";
// 三级分类组件
import Category from "./Category/index.vue";
import type { App, Component } from "vue";
// 定义一个对象，用来存储全局组件
const components: { [name: string]: Component } = { SvgIcon, Category };
import * as ElementPlusIconsVue from "@element-plus/icons-vue";

export default {
  // 只要在main.ts中use了该插件，就会执行install方法
  // install方法的第一个参数是app，就是createApp返回的实例
  install(app: App) {
    // 遍历components对象，注册全局组件
    Object.keys(components).forEach((key: string) => {
      app.component(key, components[key]);
    });

    for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
      app.component(key, component);
    }
  },
};
